#!/bin/bash

run_loop() {
    local base_dir="$1"
    if [[ ! -d "$base_dir" ]]; then
        echo "Directory $base_dir does not exist, skipping."
        return
    fi

    pushd "$base_dir" > /dev/null || return

    for dir in */; do
        if [[ -d "$dir" ]]; then
            pushd "$dir" > /dev/null || continue
            echo "--------------------"
            echo "Current directory: $(pwd)"
            if [[ -f "run.sh" ]]; then
                bash run.sh | tail -n 9
            else
                echo "run.sh not found in $dir"
            fi
            popd > /dev/null
        fi
    done

    popd > /dev/null
}

# 执行
for target in B1 B2 B4 H12 H15 H32 H80; do
    run_loop "$target"
done